<?php
namespace App\Services;

class ConsumerService
{
    protected $consumer;
    protected $userId;
    protected $scopes;

    public function initialize($consumer, $userId, $scopes)
    {
        $this->consumer = $consumer;
        $this->userId = $userId;

        $this->scopes = $scopes;
    }

    public function getConsumer()
    {
        return $this->consumer;
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function getScopes()
    {
        return $this->scopes;
    }

    public function isAdmin()
    {
        return $this->consumer === 'admin';
    }

    public function isStudent()
    {
        return $this->consumer === 'student';
    }

    public function isTeacher()
    {
        return $this->consumer === 'teacher';
    }

    // Scope
    public function isSuperAdmin()
    {
        return in_array('admin', $this->scopes);
    }

    public function isTrainer()
    {
        if($this->isSuperAdmin())
            return false;
        return in_array('admin-teacher-training', $this->scopes);
    }

    public function isTrainerLeader()
    {
        if($this->isSuperAdmin())
            return false;
        return in_array('admin-teacher-training-leader', $this->scopes);
    }

    public function isRecruiter()
    {
        if($this->isSuperAdmin())
            return false;
        return in_array('admin-teacher-hiring', $this->scopes);
    }

    public function isRecruiterLeader()
    {
        if($this->isSuperAdmin())
            return false;
        return in_array('admin-teacher-hiring-leader', $this->scopes);
    }
}